#ifndef OPENGLCTX_H
#define OPENGLCTX_H

#include <QtGui>
#include <QtOpenGL>
#include <vector>

#include "clio.h"

using namespace std;

class OpenGLctx : public QGLWidget
{
    Q_OBJECT

protected:
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();

    void MakeLighting();


public:
    explicit OpenGLctx(QWidget *parent = 0);

signals:

public slots:

private:
    void mousePressEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void wheelEvent(QWheelEvent *);

private:
    void draw();
//    int faceAtPosition(const QPoint &pos);

    GLfloat gl_width;
    GLfloat gl_height;
    GLfloat light_pos[3];
    GLfloat rotationX;
    GLfloat rotationY;
    GLfloat rotationZ;
    GLfloat distance;
    QColor faceColors[4];
    QPoint lastPos;

    vector<triangle3d> *mesh;

public:
    void setMesh(vector<triangle3d> &);
};

#endif // OPENGLCTX_H
